package com.atmc.controller;

import com.atmc.bean.User;
import com.atmc.mapper.UserMapper;
import com.atmc.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ChuController {
    @Autowired
    UserService userService;
    @Autowired
    UserMapper userMapper;
    @RequestMapping("/chuyings/saishia/a")
    public String saishi(Model model){
        List<User> list = userService.selectAll();
        model.addAttribute("msg",list);
        return "chuyings/saishi";
    }

    @RequestMapping("/chuyings/supermana/b")
    public String superman(@RequestParam(value = "pn",defaultValue = "1")Integer pn, Model model){
//        List<User> list = userService.selectAll();
        Page<User> page=new Page<>(pn,4);
        userMapper.selectPage(page,null);

        List<User> list = page.getRecords();
//        model.addAttribute("msg1",list1);
        model.addAttribute("msg",list);
        model.addAttribute("user",page);
        return "chuyings/superman";
    }
}
